//
// Created by zhou on 2021/10/20.
//
#include <iostream>
#include "unordered_map"
#include <string>
#include <map>
using namespace std;
class Solution {
public:
    string getHint(string secret, string guess) {
        int a=0,b=0;
        map<char,int> secret1;
        map<char,int> guess1;

        for(int i=0;i<secret.length();i++){
            if(secret[i]==guess[i])a++;
            else {
                secret1[secret[i]]+=1;
                guess1[guess[i]]+=1;
            }
        }

        for(auto m:secret1){
           if(guess1.find(m.first)!=guess1.end())
            b+=min(m.second,guess1.find(m.first)->second);
        }
        string m=to_string(a)+"A"+to_string(b)+"B";


        return m;

    }
};
int main(){
    Solution solution;
    string s1="12041";
    string s2="10241";
    cout<<solution.getHint(s1,s2);
}
